package com.yanqu.road.server.cmd.activity.platform;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.PlatformAntiFraudProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.platform.PlatformMailAntiActivityModule;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.platform.PlatformMailAntiActivityMgr;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = GameProtocol.S_PLATFORM_ANTI_FRAUD_GET_REWARD,desc = "拿奖励")
public class GetPlatformAntiFraudCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {

        // 没有活动
        if (!ActivityMgr.activityInTime(PlatformMailAntiActivityMgr.getActivityInfo())) {
            ret = GameErrorCode.E_ACTIVITY_OVER_TIME;
            return;
        }
        PlatformAntiFraudProto.GetPlatformAntiFraudReqMsg reqMsg = PlatformAntiFraudProto.GetPlatformAntiFraudReqMsg.parseFrom(packet.getBytes());

        ret = player.getModule(PlatformMailAntiActivityModule.class).getReward(reqMsg.getIndex());


    }

    @Override
    public void sendData(GamePlayer player) {

        if(ret != 0){
            player.sendPacket(Protocol.U_PLATFORM_ANTI_FRAUD_GET_REWARD, PlatformAntiFraudProto.GetPlatformAntiFraudRespMsg.newBuilder().setRet(ret));
        }

    }
}
